﻿@using Telerik.Web.Mvc.UI

@{
    var gridPageSize = EngineContext.Current.Resolve<SmartStore.Core.Domain.Common.AdminAreaSettings>().GridPageSize;

    //page title
    ViewBag.Title = T("Admin.ContentManagement.Blog.BlogPosts").Text;
}
<div class="section-header">
    <div class="title">
        <i class="far fa-edit"></i>
        @T("Admin.ContentManagement.Blog.BlogPosts")
    </div>
    <div class="options">
		@{ Html.RenderWidget("admin_button_toolbar_before"); }

        <a href="@Url.Action("Create")" class="btn btn-primary">
			<i class="fa fa-plus"></i>
			<span>@T("Admin.Common.AddNew")</span>
		</a>

		@{ Html.RenderWidget("admin_button_toolbar_after"); }
    </div>
</div>
<div>
	@(Html.Telerik().Grid<BlogPostModel>()
        .Name("blogpost-grid")
        .Columns(columns =>
        {
                columns.Bound(x => x.Title)
                        .Template(x => Html.ActionLink(x.Title, "Edit", new { id = x.Id }))
                        .ClientTemplate("<a href=\"Edit/<#= Id #>\"><#= Title #></a>");
                columns.Bound(x => x.LanguageName);
                columns.Bound(x => x.Comments)
                    .Template(@<div>Html.ActionLink(@item.Comments, "Comments", new { filterByBlogPostId = item.Id })</div>)
				    .ClientTemplate("<div><a href=\"Comments?filterByBlogPostId=<#= Id #>\"><#= Comments #></a></div>")
                    .Centered();
			    columns.Bound(x => x.StartDate);
			    columns.Bound(x => x.EndDate);
			    columns.Bound(x => x.CreatedOn);
                columns.Bound(x => x.IsPublished)
                    .Template(item => @Html.SymbolForBool(item.IsPublished))
				    .ClientTemplate(@Html.SymbolForBool("IsPublished"))
                    .Centered();
		    })
		    .Pageable(settings => settings.PageSize(gridPageSize).Position(GridPagerPosition.Both))
		    .DataBinding(dataBinding => dataBinding.Ajax().Select("List", "Blog"))
		    .PreserveGridState()
		    .EnableCustomBinding(true))
</div>

